 /*
 * Copyright (C) 2017-2024 Alibaba Group Holding Limited
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __AIS_OTA_SERVER_H__
#define __AIS_OTA_SERVER_H__

#include "ais_ota.h"
#include "ota_server.h"
#include "ota_process.h"

#ifndef AIS_GATT_WORK_ENVIRONMENT
#define AIS_GATT_WORK_ENVIRONMENT MESH_MODE
#endif

typedef enum
{
    AIS_OTA_SERVER_STATE_IDLE = 0x00,
    AIS_OTA_SERVER_STATE_CHAN_READY,
    AIS_OTA_SERVER_STATE_CHAN_CREATE_CONN_FAIL,
    AIS_OTA_SERVER_STATE_CHAN_CONN,
    AIS_OTA_SERVER_STATE_CHAN_DISCONN,
    AIS_OTA_SERVER_STATE_ONGOING,
} ais_ota_server_state;

typedef enum
{
    AIS_OTA_INVALID_VERSION,
    AIS_OTA_DEV_REFUSE,
} ais_ota_failed;

int ais_ota_server_init(uint8_t channel);
int ais_ota_server_prepare(uint16_t index, upgrade_firmware *firmware_info);
int ais_ota_server_ota_start();
int ais_ota_server_send_start();
int ais_ota_server_ota_stop();
int ais_ota_server_reset();
int ais_ota_server_channel_disconnect();

#endif
